## This file makes the t-SNE plot for the democracy example

load("lipset/out/lipset_out_pois.rda")

# Aggregate
# see documentation for BRS::agg_BRS
set.seed(123)
agg <- agg_BRS(fit=out_lipset_boot, X=X, Y=Y, maxLen=3, split = F, minProp = .05,
               simplify = T, oppmat=oppmat, oppind=oppind)


# plot
png("figures/lipset_tsne.png", width = 4, height = 4, units = 'in', res = 300)
set.seed(123)
plot_tsne(X, Y, agg, max_iter = 1000, pointSize = 1.25, symb = c(20, 4),
          caseColors=prettyGraphs::add.alpha(RColorBrewer::brewer.pal(8, "RdYlGn")[c(6,1)], alpha=1),
          highlight=NULL)
          #highlight=1)
          #highlight=2)
          # to see which rule covers which point, 
          # separately plot with highlight=1 (points covered by "GNPCAP_2")
          # and highlight=2 (points covered by "GNPCAP_0_neg" and "INDLAB_0")
          # In the paper, we do this to identify the points covered by the rule, 
          # then encircle them (on a graph with no highlighting) with photo-editing software
dev.off()
